pkgname=wlc
pkgver=0.0.11
pkgrel=2
pkgdesc="Wayland Compositor Library"
url="https://github.com/Cloudef/wlc"
arch=("loong64" "x86_64")
license=("MIT")
depends=(
	"libdrm" "pixman" "xcb-util-image" "xcb-util-wm"
	"wayland" "wayland-protocols" "libxkbcommon" "libinput" "libgl"
)
makedepends=("cmake")
source=(
	"https://github.com/Cloudef/$pkgname/releases/download/v$pkgver/$pkgname-$pkgver.tar.bz2"
	"https://github.com/Cloudef/$pkgname/releases/download/v$pkgver/$pkgname-$pkgver.tar.bz2.asc"
        wlc-missing-header.patch
)
sha256sums=('c2061f5d6c627688ea8b822ac5f4d3ba4d407b3f8d79267677ce4011b6390d22'
            'SKIP'
            '605a7d7b5d5d3b5c771ee9e262836b6073be89aa5737328b66ebe835bec828a6')
validpgpkeys=(
	"C2AA3C3A6F9B1F932014879EF769BB961AF6D26A"
	"9DDA3B9FA5D58DD5392C78E652CB6609B22DA89A"  # Drew DeVault <sway@cmpwn.com>
)

prepare() {
  cd $pkgname-$pkgver
  patch -p1 -i ../wlc-missing-header.patch
}

build() {
	mkdir -p build
	cd build
        CFLAGS+=' -fcommon'
	cmake "$srcdir/$pkgname-$pkgver" \
		-DCMAKE_BUILD_TYPE=Upstream \
		-DCMAKE_INSTALL_LIBDIR=/usr/lib \
		-DCMAKE_INSTALL_PREFIX=/usr
	make
}

check() {
	cd build
	make test
}

package() {
	cd build
	make DESTDIR="$pkgdir" install
	install -Dm644 "$srcdir/$pkgname-$pkgver/LICENSE" "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
